﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Documents.Common.Interfaces;
using Documents.Common.Helpers;
using System.Xml;

namespace Forms.Repository.Controllers
{
    public class FormsController : Controller, IFormRepository
    {
        public ActionResult Get(string FormID)
        {
            // Rather than returning an xmlfile which represents a form, 
            // we will return an actual, xhtml valid form, this alleiviates
            // any xslt transofrmation, and mewans that the form builder can be
            // used, as opposed to having to roll our own forms GUI
            XmlDocument result = new XmlDocument();
            result.Load(string.Format("{0}/{1}.xml", Server.MapPath(@"/Forms"),FormID));
            return new ContentResult
            {
                Content = result.OuterXml,
                ContentType = "application/xml"
            };
        }

        [HttpPost]
        public ActionResult Store()
        {
            // Process the form here!
            // then post it to the main application for storage.
            return Redirect("http://localhost:1329/Home/Store"); // SHIT! this does a GET, I want to post the request

        }
    }
}
